package com.biao.template;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *  自己的数据库操作模板类
 * @author: chenwenbiao
 * @create: 2020-2-2 12:46
 */
@Component
public class MyJdbcTemplate {

    @Autowired
    private MyConnectionManager connectionManager;

    // 要throws exception
    public void execute(String sql) throws SQLException {
        Connection connection = connectionManager.getConnection();
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.execute();
    }
}
